<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  

<title>K线图-手机横屏</title>  
    <!-- 加载资源 -->
    <link rel="stylesheet" href="../jscommon/umychart.resource/css/tools.css" />
    <link rel="stylesheet" href="../jscommon/umychart.resource/font/iconfont.css" />
</head>  
<body>
    <div id="kline" >
       
    </div>

    <div>
        <span id="button_1" class="btn-style">日</span>
        <span id="button_2" class="btn-style">周</span>
        <span id="button_3" class="btn-style">月</span>

        <span id="button_4" class="btn-style">1M</span>
        <span id="button_5" class="btn-style">5M</span>
        <span id="button_6" class="btn-style">15M</span>

        <span id='button_7' class="btn-style">RSI</span>
    </div>

    <script src="../jscommon/umychart.resource/js/jquery.min.js"></script>
    <script src="../jscommon/umychart.resource/js/webfont.js"></script>
    <script src='../jscommon/umychart.console.js'></script>     <!-- 日志输出 -->
    <script src="../jscommon/umychart.network.js"></script>     <!-- 网络请求分装 -->
    <script src="../jscommon/umychart.js"></script>             <!-- K线图形 -->
    <script src="../jscommon/umychart.complier.js"></script>    <!-- 麦语言解析执行器 -->
    <script src="../jscommon/umychart.index.data.js"></script>  <!-- 基础指标库 -->
    <script src="../jscommon/umychart.style.js"></script>       <!-- 白色风格和黑色风格配置信息 -->

    <script src="../jscommon/umychart.NetworkFilterTest.js"></script>
   
    <script>

        MARKET_SUFFIX_NAME.GetMarketStatus = function (symbol)  { return 2; }
        
        //简单的把K线控件封装下
        function KLineChart(divKLine)
        {
            this.DivKLine=divKLine;
            this.Chart=JSChart.Init(divKLine, false, true);   //把K线图绑定到一个Div上
          
            //K线配置信息
            this.Option= {
                //Type:'历史K线图',   //创建图形类型
                Type:'历史K线图横屏',

                //EnableBorderDrag:false,
                
                Windows: //窗口指标
                [
                    {Index:"MA" },
                    {Index:"MACD"},
                    {Index:"VOL"},
                ], 

                
                OverlayIndex:
                [
                   //{ Index:'MA', Windows:0 , IsShareY:true, ShowRightText:false , IsShowIndexTitle:true, FloatPrecision:5 },
                    //{Index:'RSI', Windows:0, ShowRightText:false },
                    //{ Index:'BOLL', Windows:0, ShowRightText:true,IsShareY:true, ShowToolbar:true },
                   // {Windows:0, IndexName:"指标ID", Name:"自定义指标", Script:"DRAWTEXT(CLOSE<OPEN,H,14),VALIGN2,ALIGN1,YMOVE(-10), XMOVE(5);", Identify:"guid_66990",ShowRightText:true,IsShareY:true }
                    //{Index:'MA5', Windows:1 ,ShowRightText:true}
                    //{Index:"VOL_OVERLAY", Windows:0 },
                ],  //叠加指标
                

                //OverlayIndexFrameWidth:1,
                //DragDownload: { Day:{ Enable:true } , Minute:{ Enable:true }}, 

                EnableZoomUpDown:
                {
                    //Wheel:false,
                    //Keyboard:false,
                    //Touch:false,
                },

                EnableYDrag:
                {
                    Right:true,
                    Left:true,
                },

                //Language:'EN',

                Symbol:"600000.sh",
                IsAutoUpdate:true,       //是自动更新数据
                AutoUpdateFrequency:3000,   //数据更新频率
                //TradeIndex: {Index:'交易系统-BIAS'},    //交易系统

                SplashTitle:'加载数据中......',
    
                IsShowRightMenu:true,          //右键菜单
                CorssCursorTouchEnd:true,
                IsClickShowCorssCursor:true,
                //IsCorssOnlyDrawKLine:true,

                CtrlMoveStep:10,

                //EnableVerifyRecvData:true,

                CorssCursorInfo: { Right:2, DateFormatType:3, HPenType:1, VPenType:1, IsShowClose:false, VLineType:0,RightButton:{ Enable:true }, IsShowCorss:true, PriceFormatType:0, DataFormatType:0 },
                EnableZoomIndexWindow:true,

                DrawTool:       //画图工具
                {
                    //StorageKey:'4E7EA133-D6C8-4776-9869-1DDDCC5FA744'
                },
    
                KLine:  //K线设置
                {
                    DragMode:1,                 //拖拽模式 0=禁止拖拽 1=数据拖拽 2=区间选择
                    Right:1,                    //复权 0 不复权 1 前复权 2 后复权
                    Period:0,                   //周期 0 日线 1 周线 2 月线 3 年线 
                    MaxRequestDataCount:3000,   //数据个数
                    MaxRequestMinuteDayCount:5, //分钟数据获取几天数据  默认取5天数据
                    
                    //Info:["互动易","大宗交易",'龙虎榜',"调研","业绩预告","公告"],       //信息地雷
                    //Info:["公告"], 
                    IsShowTooltip:false,                 //是否显示K线提示信息
                    DrawType:0,      //K线类型 0=实心K线柱子 1=收盘价线 2=美国线 3=空心K线柱子 4=收盘价面积图
                    //FirstShowDate:20161201,
                    KLineDoubleClick:false, //禁止双击弹框
                    RightSpaceCount:2,
                    ZoomType:0,
                    
                    //PageSize:30,               //一屏显示多少数据
                    DataWidth:10,
                },

                StepPixel:0,

                IsDrawPictureXY:true,

                Listener:
                {
                    //KeyDown:false,
                    //Wheel:false
                },

                SelectedChart:{ EnableSelected: true, EnableMoveOn:true },
                EnableIndexChartDrag:true,
    
                KLineTitle: //标题设置
                {
                    IsShowName:true,       //不显示股票名称
                    IsShowSettingInfo:true, //不显示周期/复权
                    IsTitleShowLatestData:true,
                },
    
                EnableYDrag:
                {
                    Right:true,
                    Left:true,
                },
                
                Border: //边框
                {
                    Left:22,         //左边间距
                    Right:25,       //右边间距
                    Bottom:25,      //底部间距
                    Top:25,         //顶部间距

                    AutoLeft:{ Blank:10, MinWidth:30 },
                    AutoRight:{ Blank:5, MinWidth:60 },
                },
                
                Frame:  //子框架设置
                [
                    {
                        SplitCount:6, 
                        
                        Custom:
                        [
                            
                            { 
                                Type:0,
                                Position:'right',LineType:1, 
                                //PositionEx:1,
                            },
                            
                            { 
                                Type:1, 
                                Position:'right',IsShowLine:true, LineType:0,
                                //PositionEx:1,
                                Data:
                                [
                                    {
                                        Value:7.73,
                                        Color:'rgb(0, 0 ,205)', TextColor:'rgb(255,255,255)',    //Color:线段及文字背景色 TextColor:文字颜色
                                        Text:[ {Text:"价格:9.73"}, {Text:"成本线"} ]
                                    },
                                    {
                                        Value:6.50,
                                        Color:'rgb(255 ,165, 79)', TextColor:'rgb(255,255,255)',    //Color:线段及文字背景色 TextColor:文字颜色
                                    }
                                ] 
                            },

                            { 
                                Type:1, 
                                Position:'right',IsShowLine:true,LineType:1,PositionEx:1, LineWidth:2, LineDash:[4,4],
                                Data:
                                [
                                    {
                                        Value:8.0,
                                        Color:'rgb(255,185,255)', TextColor:'rgb(255,255,255)',    //Color:线段及文字背景色 TextColor:文字颜色
                                    },
                                    {
                                        Value:5.51,
                                        Color:'rgb(255,185,0)', TextColor:'rgb(255,255,255)',    //Color:线段及文字背景色 TextColor:文字颜色
                                    }
                                ] 
                            }
                        ]
                        
                        
                        
                    },

                    { SplitCount:5 },
                    { SplitCount:4 }
                ],

                ExtendChart:    //扩展图形
                [
                    {Name:'KLineTooltip' },  //手机端tooltip
                ],


                Overlay:
                [
                    //{Symbol:'399300.sz', DrawType:1, Color:'rgb(0,0,255)'},
                    //{ Symbol:'600999.sh' }
                ],
            };
                 
            this.Create=function()  //创建图形
            {
                var self=this;
                //$(window).resize(function() { self.OnSize( {Type:1} ); });    //绑定窗口大小变化事件
                $(window).resize(function() { self.OnSize( ); });    //绑定窗口大小变化事件

                var blackStyle=HQChartStyle.GetStyleConfig(STYLE_TYPE_ID.BLACK_ID); //读取黑色风格配置
                JSChart.SetStyle(blackStyle);
                this.DivKLine.style.backgroundColor=blackStyle.BGColor; //设置最外面的div背景
                JSChart.GetResource().ToolbarButtonStyle=1;

                this.OnSize();  //让K线全屏
                this.Option.NetworkFilter=(data, callback)=>{ HQData.NetworkFilter(data, callback); }
                this.Chart.SetOption(this.Option);  //设置K线配置

            }

            this.OnSize=function(option)  //自适应大小调整
            {
                var height= $(window).height()-50;
                var width = $(window).width();
                //width=50000;
                this.DivKLine.style.top='0px';
                this.DivKLine.style.left='0px';
                this.DivKLine.style.width=width+'px';
                this.DivKLine.style.height=height+'px';
                this.Chart.OnSize(option);
            }

            this.ChangeSymbol=function(symbol)
            {
                this.Chart.ChangeSymbol(symbol);
            }

            this.ChangeIndexCount=function()
            {
                //已经存在的指标不会改变，新的窗口使用option的配置指标
                var option=
                { 
                    Windows:
                    [
                        {Index:"MA", Modify:true,Change:false},
                        {Index:"MACD2"},
                        {Index:"MACD",Modify:false, Change:true, Close:true,IsShowLeftText:false},
                        {Index:"VOL", Args:[ { Name:'M1', Value:6} ,{ Name:'M2', Value:8}] , Modify:false,Change:false, Close:true,IsShowLeftText:false },
                    ],
                };

                this.Chart.ChangeIndexWindowCount(4,option);
            }

            this.OverlayIndex=function()
            {
                var option={WindowIndex:0, IndexName:"指标ID", Name:"自定义指标", Args:[{Name:"T", Value:5}],
                Script:"T:MA(O,20);DRAWTEXT_LINE(O>C,13,'13.00',RGB(0,33,3), 10,1, RGB(0,255,0));", Identify:"guid_66990"};
                //var option={WindowIndex:0, IndexName:"MACD", Identify:"guid_66990"};
                this.Chart.AddOverlayIndex(option);
            }

            this.ChangeIndex=function(windowIndex,indexName,option)
            {
                this.Chart.ChangeIndex(windowIndex,indexName,option);
            }

            this.AddIndexWindow=function(indexName)
            {
                this.Chart.AddIndexWindow(indexName);
            }
        }

        $(function () 
        {
            WebFont.load({ custom: { families: ['iconfont'] } });   //预加载下iconfont资源
           
            var klineControl=new KLineChart(document.getElementById('kline'));
            klineControl.Create();

            $("#button_7").click(function() { klineControl.AddIndexWindow("RSI"); } );

            $("#button_1").click(function() { klineControl.Chart.ChangePeriod(0); } );
            $("#button_2").click(function() { klineControl.Chart.ChangePeriod(1); } );
            $("#button_3").click(function() { klineControl.Chart.ChangePeriod(2); } );

            $("#button_4").click(function() { klineControl.Chart.ChangePeriod(4); } );
            $("#button_5").click(function() { klineControl.Chart.ChangePeriod(5); } );
            $("#button_6").click(function() { klineControl.Chart.ChangePeriod(6); } );

        })

      
    </script>  
</body>  
</html>



<style>

#kline
{
    width: 900px;
    height:400px;
    position: relative;
    /*margin-top: 100px;*/
}

.btn-style
{
    padding: 3px 8px;
    border: 1px solid #ececec;
    border-radius: 5px;
    background-color: #f5f5f5;
    cursor: pointer;
}

    
</style>